package sort;

import java.util.Arrays;

/**
 * 针对 Algorithm 算法的复习
 */
public class AlgorithmReview {
    static int[] num = new int[]{2, 3, 1, 3, 4, 6};

    public static void main(String[] args) {
        shellSort();
    }

    /**
     * 插入排序-希尔排序
     */

    public static void shellSort(){
        int len = num.length;
        int temp = 0;
        for (int gap = len/2; gap > 0 ; gap/=2) {
            for (int i = gap; i < len; i++) {
                for (int j = i - gap; j >=0 ; j-=gap) {
                    if(num[j] > num[j + gap]){
                        temp = num[j];
                        num[j] = num[j + gap];
                        num[j + gap] = temp;
                    }
                }
            }
        }
        System.out.println(Arrays.toString(num));
    }

    /**
     * 递归函数
     * @param n
     * @return
     */
    public static int getSum(int n){
        if(n == 1){
           return 1;
        }
        return n + getSum(n - 1);
    }
}
